﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sucdri.Domain.Model;
using Sucdri.Infrastructure.Core.Extensions;

namespace Sucdri.Domain.Repository.DataMapper
{
   internal class ProjectMainDataMapper:BaseDataMapper
   {
      protected override string GetInsertCommand()
      {
         return "INSERT INTO RprjMain VALUES(@RprjNum,@RprjName,@RprjPlatformID,@RprjRoleID)";
      }

      protected override string GetUpdateCommand()
      {
         return "UPDATE RprjMain SET RprjNum=@RprjNum,RprjName=@RprjName,RprjPlatformID=@RprjPlatformID,RprjRoleID=@RprjRoleID WHERE RprjID=@RprjID";
      }

      protected override string GetDeleteCommand()
      {
         return "DELETE FROM RprjMain WHERE RprjID=@RprjID";
      }

      protected override IDictionary<string, object> BuildInsertParameter(DomainEntity entity)
      {
         var projectMain = entity as ProjectMain;
         return new Dictionary<string, object>().AddOrReplace("RprjNum", projectMain.RprjNum)
            .AddOrReplace("RprjName", projectMain.RprjName)
            .AddOrReplace("RprjPlatformID", projectMain.RprjPlatformID)
            .AddOrReplace("RprjRoleID", projectMain.RprjRoleID);
      }

      protected override IDictionary<string, object> BuildUpdateParameter(DomainEntity entity)
      {
         var projectMain = entity as ProjectMain;
         return new Dictionary<string, object>().AddOrReplace("RprjNum", projectMain.RprjNum)
            .AddOrReplace("RprjName", projectMain.RprjName)
            .AddOrReplace("RprjPlatformID", projectMain.RprjPlatformID)
            .AddOrReplace("RprjRoleID", projectMain.RprjRoleID)
            .AddOrReplace("RprjID", projectMain.Id);
      }

      protected override IDictionary<string, object> BuildDeleteParameter(DomainEntity entity)
      {
         var projectMain = entity as ProjectMain;
         return new Dictionary<string, object>().AddOrReplace("RprjID", projectMain.Id);
      }
   }
}
